#include <hid.h>
#include <hiduniversal.h>
#include <usbhub.h>

#include "hidjoystickrptparser.h"

#define LEDPIN1 6
#define LEDPIN2 5

USB Usb;
USBHub Hub(&Usb);
HIDUniversal Hid(&Usb);
JoystickEvents JoyEvents;
JoystickReportParser Joy(&JoyEvents);
int poop_On_Will;

void setup() {
        pinMode(LEDPIN1, OUTPUT);
        pinMode(LEDPIN2, OUTPUT);
        digitalWrite(LEDPIN1, LOW);
        digitalWrite(LEDPIN2, LOW);
  
        Serial.begin(115200);
        while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
        Serial.println("Start");

        if (Usb.Init() == -1)
                Serial.println("OSC did not start.");

        delay(200);

        if (!Hid.SetReportParser(0, &Joy))
                ErrorMessage<uint8_t > (PSTR("SetReportParser"), 1);
}

void loop() {
        Usb.Task();
        poop_On_Will = int(Joy.oldButtons);
        if(poop_On_Will == 1) {
          digitalWrite(LEDPIN1, HIGH);
        }else {
          digitalWrite(LEDPIN1, LOW);
        }
        if(poop_On_Will == 2) {
         digitalWrite(LEDPIN2, HIGH); 
        }else {
         digitalWrite(LEDPIN2, LOW); 
        }
}

